import request from '@/utils/request'
import {POS_SERVER_URL} from '@/utils/common'
import {getSignedParams} from '@/utils/sign'

// 锁定加油记录
export function lockFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/lock',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 解锁加油记录
export function unlockFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/unlock',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 强制解锁加油记录
export function forceUnlockFuelRecord (data) {
  data.forceUnlock = true
  return unlockFuelRecord(data)
}

// 锁定预付款记录
export function lockPrePayRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/prepay-record/lock',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 解锁预付款记录
export function unlockPrePayRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/prepay-record/unlock',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 购物车结算
export function cartSettle (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/cartSettle',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 优惠券选择
export function couponSelect (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/couponSelect',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 查询支付结果
export function queryPayResult (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/queryPayResult',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 油品消费退款
export function fuelRefund (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/fuelRefund',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 便利店消费退款
export function storeRefund (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/storeRefund',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 预付款勾兑接口
export function prePayMatchUp (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/prePayMatchUp',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 待结算拆单
export function splitOrder (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/splitOrder',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 撤销拆单
export function cancelSplitOrder (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/cancelSplitOrder',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 获取非油优惠金额
export function getStorePromotionDiscount (data) {
  return request({
    url: POS_SERVER_URL + '/api/settle/storePromotionDiscount',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 消单-删除待结算记录
export function deleteFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/delete',
    method: 'post',
    data: getSignedParams(data)
  })
}

// 获取加油记录的秒付历史
export function getAmountCheckList (id) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/getAmountCheckList',
    method: 'post',
    data: getSignedParams({id: id})
  })
}

// 删除所有待结算记录
export function deleteAllFuelRecord (data) {
  return request({
    url: POS_SERVER_URL + '/api/fuel-record/deleteAll',
    method: 'post',
    data: getSignedParams(data)
  })
}
